package com.springmq.mq.juc;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName : Demo6
 * @Author : lby
 * @Date: 2021/2/4 16:10
 * @Description :
 */
public class Demo6 {

    public static void main(String[] args) {
        // 创建一个线程池
        ThreadPoolExecutor poolExecutor = null;
        try {
            poolExecutor = new ThreadPoolExecutor(2,2,2, TimeUnit.SECONDS,new SynchronousQueue<Runnable>());
            poolExecutor.execute(()->{
                System.out.println("这是一个线程");
            });
            // 线程创建之后要关闭
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            poolExecutor.shutdown();
        }

    }
}
